
var mainCustomerIds=sessionStorage.getItem("mainCustomerId");
console.log(mainCustomerIds);
var lableidarr={}
//查询
showRelevance()
function showRelevance() {
    lableidarr={}
    $.ajax({
        type: "get",
        url:''+root.member.getLabelsByMainCustomerId+'?'+"mainCustomerId"+'='+mainCustomerIds+'',
        dataType: "json",
        async:false,//优先运行
        data: {

        },
        //传入组装的参数
        success: function (data) {
            for (var i = 0; i < data.data.length; i++) {
                lableidarr[data.data[i]]=[]
            }

        }
    })
}
//信息
goods_listCategory1();
function goods_listCategory1() {
    var user_data = {
        lableLevel: 1,
        platformType:20
    }
    var succCallBack = function (data, status, response) {
        if (data.data.length == 0) {
            $("#classSet1").append('<li class="clearfix pl-10 mb-5"  style="width: 95%" >无数据</li>');
        }
        else {
            $("#classSet1").html("")
            for (var i = 0; i < data.data.length; i++) {
                if(lableidarr!=""){
                        if(lableidarr.hasOwnProperty(data.data[i].lable_id)){
                            $("#classSet1").append('<li class="clearfix pl-10 mb-5"  style="width: 95%"><div class="f-l pd-5">' +
                                '<input  name="classification01" type="checkbox" checked value="' + data.data[i].lable_id + '" class="checkbox" />' +
                                '<label  class="pl-10"> ' + data.data[i].lable_name + '</label></div>' +
                                '</li>')
                        }else {
                            $("#classSet1").append('<li class="clearfix pl-10 mb-5"  style="width: 95%" ><div class="f-l pd-5">' +
                                '<input  name="classification01" type="checkbox" value="' + data.data[i].lable_id + '" class="checkbox" />' +
                                '<label  class="pl-10"> ' + data.data[i].lable_name + '</label></div>' +
                                '</li>')
                        }
                }else {
                    $("#classSet1").append('<li class="clearfix pl-10 mb-5"  style="width: 95%" ><div class="f-l pd-5">' +
                        '<input  name="classification01" type="checkbox" value="' + data.data[i].lable_id + '" class="checkbox" />' +
                        '<label  class="pl-10">' + data.data[i].lable_name + '</label></div>' +
                        '</li>')
                }


            }
        }


    };
    return web.doAjax(root.goodsInter.listLableByType, 'get', user_data, succCallBack);
}


//保存
function addshowRelevance() {
    var labelIdListarr=[]
    var classification01s= document.getElementsByName("classification01")
    for (var i=0;i<classification01s.length;i++) {
        if(classification01s[i].checked){
            labelIdListarr.push($(classification01s[i]).val())
        }
    }
    $.ajax({
        contentType: 'application/json',
        url: root.member.saveMainCustomerLabels,
        cache: false,  //禁用缓存
        type: "POST",
        data: JSON.stringify({
            "mainCustomerId": mainCustomerIds,
            "labelIdList": labelIdListarr,
        }),

        success: function (data) {
            if (data.errorCode == 0) {
                $.Huimodalalert('保存成功', 3000);
                setTimeout(function () {
                    parent.layer.closeAll();
                }, 700);

            } else {
                layer.msg(data.msg, {icon: 5, time: 1000});
            }

        },
        error: function () {
            layer.msg("保存失败,请重新提交！", {icon: 5, time: 1000});
        }
    });
}
// 取消
function cancelshowRelevance(){
    // 关闭当前页面
    parent.layer.closeAll();
}


function skipPage(){
    $("#carouseMap-box").load("/homeet/html/Customer/accountAystem/carouselMap.html");
}